{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>banner添加</h5>
        </div>
        <div class="ibox-content">
            <form class="layui-form" action="" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">位置</label>
                    <div class="layui-input-block">
                        <select name="type" lay-filter="aihao">
                            <option value="1" selected="">首页</option>
                            <option value="2">目的地</option>
                            <option value="3">攻略</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item key">
                    <label class="layui-form-label" >名称</label>
                    <div class="layui-input-block" >
                        <input required type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item key">
                    <label class="layui-form-label" >图片</label>
                    <div class="layui-input-block" >
                        <input id="src" type="hidden" value="" name="src">
                        <img width="200px" id="img" src="" style="display: none;">
                        <button type="button" class="layui-btn" id="test1">
                            <i class="layui-icon">&#xe67c;</i>上传图片
                        </button>
                    </div>
                </div>
                <div class="layui-form-item key">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input required value="0" type="number" name="sort" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item key">
                    <label class="layui-form-label">跳转链接</label>
                    <div class="layui-input-block ee">
                        <input required type="text" name="url" lay-verify="title" autocomplete="off" placeholder="例如：http://www.baidu.com" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否显示</label>
                    <div class="layui-input-block">
                        <select name="is_show" lay-filter="aihao">
                            <option value="0" selected="">不显示</option>
                            <option value="1">显示</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>

        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

{include file="public/footer" /}
<script>

    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: '/admin/upload/upload' //上传接口
            ,done: function(res){
                //上传完毕回调
                if(res.code == 200){
                    $('#src').attr('value',res.data.src);
                    $('#img').attr('src',res.data.src);
                    $('#img').css('display','');
                    layer.msg('上传成功', {icon: 1});
                }else {
                    layer.msg(res.msg, {icon: 2});
                }

            }
            ,error: function(){
                //请求异常回调
            }
        });
    });
</script>


</body>
</html>